package StudyCode.summary.zipfile;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopyingFileToAnOutputStream {
	public static void main(String[] args) {
		Path sourceFile = FileSystems.getDefault().getPath("E:/Copy/2.txt");
		try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
			Files.copy(sourceFile, outputStream);
			byte arr[] = outputStream.toByteArray();
			System.out.println("文件内容是 " + sourceFile.getFileName());
			for (byte data : arr) {
				System.out.print((char) data);
			}
			System.out.println();
		} catch (IOException ex) {
			ex.printStackTrace();
		}

	}
}
